BigDFT.UnitCells module

A module for handling unit cells for periodic calculations.

class UnitCell(cell=None, units='bohr')[source]

Defines a wrapper for unit cells.

Parameters:
  • cell (list) – a list of unit cell vectors. This can either be a 3x1 list or a 3x3 list. Currently, only orthorhombic cells are supported. units (str): the units of the cell parameters. If cell is set to None, the free boundary condition is enforced.

  • units (str) – the unit of length.

get_boundary_condition(units='bohr')[source]

Get a string description of the boundary condition (i.e. free, surface, wire, periodic)

Parameters:

units (str) – the units to report the cell in.

Returns:

a string description of the boundary condition.

Return type:

(str)

get_posinp(units='bohr')[source]

Create the dictionary representation of the cell that is passed to BigDFT.

Returns:

a list of the three values of the unit cell.

Return type:

(list)

minimum_image(pos, units='bohr')[source]

Given a vector of three positions, this wraps those positions inside the cell using the minimum image convention.

Returns:

a list of the values of the wrapped position.

Return type:

(list)

to_cartesian(pos)[source]

Convert a vector which is in reduced units to cartesian units.

Returns:

the position in cartesian coordinates.

Return type:

(list)

to_reduced(pos)[source]

Convert a vector which is in cartesian units to reduced units.

Returns:

the position in reduced coordinates.

Return type:

(list)

get_length_angle(units='bohr')[source]

Returns a description of the unit cell in terms of side lengths and angles.

Returns:

list of 3 sides. (list): list of 3 angles.

Return type:

(list)

mirror_point(pos)[source]

Given a point in space, this returns a list of points replicated across all periodic boundaries.

Parameters:

pos (list) – list of three points.

Returns:

the list of points (including the original point).

Return type:

(list)

tiling_vectors(n)[source]

Given a cell, computed the displacement vectors associated to its repetition n times in the periodic directions (from -n to n)

Parameters:

n (int or array) – number of repetition

Returns

(list): the displacement vectors (list): the periodic cell indices

_example()[source]

The following is an example of module usage:

# Create a basic unit cell
cell = UnitCell([10, 8, 4], units="angstroem")

# Print out the posinp representation
print(cell.get_posinp())
print(cell.get_posinp(units="angstroem"))

# Right now we enforce the orthorhombic condition
try:
    cell = UnitCell([[10, 0, 0], [0, 8, 0], [0, 4, 10]])
except ValueError as e:
    print(e)
cell = UnitCell([[10, 0, 0], [0, 8, 0], [0, 0, 4]])
print(cell.get_boundary_condition("angstroem"))

# Wire boundary condition
wire = UnitCell([float("inf"), float("inf"), 4])
print(wire.get_posinp())
print(wire.get_boundary_condition())

# Surface boundary condition
surface = UnitCell([10, float("inf"), 4])
print(surface.get_posinp())
print(surface.get_boundary_condition())

# Wrap positions to the minimum image convention.
pos = [-5, -2, -3]
print(cell.minimum_image(pos))
print(wire.minimum_image(pos))
print(surface.minimum_image(pos))

pos = [15, 12, 13]
print(cell.minimum_image(pos))
print(wire.minimum_image(pos))
print(surface.minimum_image(pos))